package fr.utbm.gi.vi51.slizers.pw.gui.simulation;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.border.Border;

import fr.utbm.gi.vi51.slizers.pw.WorldManager;
import fr.utbm.gi.vi51.slizers.pw.environment.WorldElement;
import fr.utbm.gi.vi51.slizers.pw.environment.WorldState;



public class SimulationPanel extends JPanel
{

	/**
	 * Version number associated to the serializable class.
	 */
	private static final long	serialVersionUID	= 5298881898989095062L;
	
	/**
	 * The world to display
	 */
	private WorldPanel world;
	
	/**
	 * The buttons panel
	 */
	private SimulationButtonsPanel simulationButtonsPanel;
	
	/**
	 * Constructor.
	 */
	public SimulationPanel()
	{
		this.world = new WorldPanel();
		
		this.setLayout( new BorderLayout() );
		
		this.add( this.world, BorderLayout.CENTER );
		
		this.simulationButtonsPanel = new SimulationButtonsPanel();
		
		this.add( this.simulationButtonsPanel, BorderLayout.NORTH );
		
	}
	
	/**
	 * Sets the last world state.
	 * 
	 * @param _lastState the last world state
	 */
	public void setLastState( WorldState _lastState )
	{
		this.world.setLastState( _lastState );
	}
	
	/**
	 * Sets the last world map.
	 * 
	 * @param _lastMap the last world map
	 */
	public void setLastMap( List< List< WorldElement >> _lastMap )
	{
		this.world.setLastMap( _lastMap );
	}
	
	/**
	 * The size of world cells.
	 * 
	 * @param _cellSize the new cell size
	 */
	public void setCellSize( int _cellSize )
	{
		this.world.setCellSize( _cellSize );
	}
	
	/* (non-Javadoc)
	 * @see javax.swing.JComponent#paint(java.awt.Graphics)
	 */
	@Override
	public void paint( Graphics _graphics )
	{
		super.paint( _graphics );
		
		this.world.repaint();
	}

}
